<template>
    <div>
        <a-modal
            v-model:visible="visible"
            width="100%"
            wrapClassName="full-dataRevision-modal"
            :maskClosable="false"
            :destroyOnClose="true"
            :forceRender="true"
        >
            <template slot="title">
                <!-- <div> -->
                    <span style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" >
                        {{ currentData.fsxmc }}
                        <span>{{ currentData.fqymc }}</span>
                        <span
                        v-if="currentData.fslbh" 
                        style="display: inline-block;border:2px solid #4eef66;border-radius: 17.3px;color: #4eef66;margin-left: 10px;font-size: 14px;"
                        >{{ currentData.fslbh }}</span>
                    </span>
                <!-- </div> -->
            </template>
            <a-spin size="large" :spinning="spinning" :key="spinningKey">
                <div class="dataRevision-content-box" >
                    
                    <div class="top-handle-v">
                        <div style="font-weight: 600;font-family: KaiTi !important;color: #38f;display: flex;align-items: center;">
                            <div>
                                <span style="display: inline-block;border:2px solid #ff9200;padding: 0 5px;border-radius: 17.3px;color: #ff9200;margin-right: 10px;font-size: 18px;">{{ currentData.fhjmc }}</span>
                                <!-- <span>{{ currentData.fqymc }}</span> -->
                            </div>
                            <!-- <span v-if="currentData.fslbh" style="display: inline-block;border:2px solid #4eef66;padding: 0 5px;border-radius: 17.3px;color: #4eef66;margin-left: 10px;font-size: 14px;">{{ currentData.fslbh }}</span> -->
                        </div>
                        <div style="display: flex;align-items: center;">
                            <div style="display: flex;align-items: center;margin-left: 50px;">
                                <a-button v-if="currentData.fhjmc == '填写修订信息' && !isView" style="margin-right: 15px;" class="orange-btn" type="primary" @click="revokeChange" icon="rollback">撤销申请</a-button>
                                <a-button v-if="currentData.fhjmc == '修订审核' && !isView" style="margin-right: 15px;" @click="returnProcess('sjxdsubmitFlow')" icon="rollback">退回</a-button>

                                <a-button v-if="!currentData.isApply && !isView" style="margin-right: 30px;" class="blue-btn" type="primary" @click="linkHandling('sjxdsubmitFlow')" icon="check-circle">提交</a-button>
                                <a-button @click="refreshClick()" icon="reload">刷新</a-button>
                            </div>
                        </div>
                    </div>
                    <div class="process-handling-card" style="margin-top: 8px;">
                        <a-tabs type="card" v-model:activeKey="activeKey" @change="tabPaneChange" v-if="!currentData.isApply" >
                            <a-tab-pane key="数据修订信息" tab="数据修订信息"></a-tab-pane>
                            <a-tab-pane key="流转记录" tab="流转记录"></a-tab-pane>
                        </a-tabs>
                    </div>
                    <div v-if="activeKey == '数据修订信息'" class="dataRevision-increase-content" :key="dataRevisionIncreaseContentKey" >
                        <div class="dataRevision-toolbox-form-box1" >
                            <a-form-model
                                class="form-model-big-box"
                                ref="ruleForm"
                                :model="formData"
                                :rules="rules"
                                layout="inline"
                            >
                                <a-descriptions bordered style="width: 100%;" >
                                    <a-descriptions-item :span="2">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" >*</span>
                                            修改类型
                                        </span>
                                        <a-form-model-item ref="fxglx" prop="fxglx">
                                            <a-radio-group v-model="formData.fxglx" v-if="currentData.fhjmc == '数据修订申请' && !isView">
                                                <a-radio value="审评信息">审评信息</a-radio>
                                                <a-radio value="方案修改">方案修改</a-radio>
                                            </a-radio-group>
                                            <span v-else >{{ formData.fxglx }}</span>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item v-if="!currentData.isApply" :span="2">
                                        <span slot="label" class="descriptions-label-slot" >
                                            <span style="display: flex;justify-content: space-between;width: 57px;">
                                                <span>申</span>
                                                <span>请</span>
                                                <span>人</span>
                                            </span>
                                        </span>
                                        <a-form-model-item >
                                            <span>{{ currentData.fsqrmc }}</span>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item v-if="!currentData.isApply" :span="2">
                                        <span slot="label" class="descriptions-label-slot" >
                                            申请部门
                                        </span>
                                        <a-form-model-item >
                                            <span>{{ currentData.fsqbm }}</span>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="2" >
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" >*</span>
                                            申请日期
                                        </span>
                                        <a-form-model-item required prop="fsqrq">
                                            <a-date-picker v-if="!isView" @change="fsqrqChange" v-model="formData.fsqrq" placeholder="请选择申请日期" />
                                            <span v-else >{{ moment(formData.fsqrq).format('YYYY-MM-DD') }}</span>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="4">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" >*</span>
                                            申请理由
                                        </span>
                                        <a-form-model-item prop="fsqly" class="zm-form-model">
                                            <div style="width: 100%;margin-top: 2px;">
                                                <a-textarea 
                                                    style="width: 100%;"
                                                    v-if="!isView"
                                                    v-model="formData.fsqly"
                                                    :autosize="{ minRows: 2, maxRows: 10000 }"
                                                    placeholder="请输入其他说明"
                                                    @blur="updateData('fsqly',formData.fsqly)"
                                                ></a-textarea>
                                                <span v-else >{{ formData.fsqly }}</span>
                                            </div>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="6" v-if="currentData.isApply">
                                        <span slot="label" class="descriptions-label-slot" >
                                            <span style="color: #fff;" class="xhText" >*</span>
                                            <span style="display: flex;justify-content: space-between;width: 57px;">
                                                <span>操</span>
                                                <span>作</span>
                                            </span>
                                        </span>
                                        <a-form-model-item class="zm-form-model">
                                            <a-button class="blue-btn" type="primary" @click="initiateApplicationClick()" icon="edit">发起修订申请</a-button>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    <div style="height: 40px;width: 100%;" v-if="!currentData.isApply  && formData.fxglx == '审评信息'" ></div>
                                    <div style="height: 40px;width: 100%;" v-if="!currentData.isApply  && formData.fxglx == '审评信息'" ></div>
                                    <div style="height: 40px;width: 100%;" v-if="!currentData.isApply  && formData.fxglx == '审评信息'" ></div>
                                    <a-descriptions-item :span="6" v-if="!currentData.isApply  && formData.fxglx == '审评信息' && !isView">
                                        <span slot="label" class="descriptions-label-slot" >
                                            <span style="color: #fff;" class="xhText" >*</span>
                                            <span style="display: flex;justify-content: space-between;width: 57px;">
                                                <span>操</span>
                                                <span>作</span>
                                            </span>
                                        </span>
                                        <a-form-model-item class="zm-form-model">
                                            <a-button style="margin-right: 10px;" class="green-btn" type="primary" @click="addPersonnelClick()" icon="plus-circle">新增人员</a-button>
                                            <a-button class="red-btn" type="primary" @click="removePersonnelClick()" icon="minus-circle">移除人员</a-button>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="2" v-if="!currentData.isApply  && formData.fxglx == '审评信息'">
                                        <span slot="label" class="descriptions-label-slot">
                                            新增人员
                                        </span>
                                        <a-form-model-item >
                                            <div class="fjcyxm-list-box" >
                                                <span class="fjcyxm-item-v" v-for="(item,index) in checkInformationData.addList" :key="index" >
                                                    <span>{{ item.fjcyxm }}（{{ item.fjcsf }}）</span>
                                                    <!-- <a-icon @click="personnelChanges(item,'shanchu')" class="minus-circle-icon" type="minus-circle" /> -->
                                                    <a-icon v-if="isView" @click="personnelChanges(item,'shanchu')" class="minus-circle-icon" type="delete" />
                                                </span>
                                            </div>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="2" v-if="!currentData.isApply  && formData.fxglx == '审评信息'">
                                        <span slot="label" class="descriptions-label-slot">
                                            移除人员
                                        </span>
                                        <a-form-model-item >
                                            <div class="fjcyxm-list-box">
                                                <span class="fjcyxm-item-v" v-for="(item,index) in checkInformationData.removeList" :key="index" >
                                                    <span>{{ item.fjcyxm }}（{{ item.fjcsf }}）</span>
                                                    <!-- <a-icon @click="personnelChanges(item,'新增')" class="plus-circle-icon" type="plus-circle" /> -->
                                                    <a-icon v-if="!isView" @click="personnelChanges(item,'删除')" class="minus-circle-icon" type="delete" />
                                                </span>
                                            </div>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="4" v-if="!currentData.isApply  && formData.fxglx == '审评信息'">
                                        <span slot="label" class="descriptions-label-slot">
                                            原审评人员
                                        </span>
                                        <a-form-model-item >
                                            <div class="fjcyxm-list-box">
                                                <span class="fjcyxm-item-v" v-for="(item,index) in checkInformationData.orgList" :key="index" >
                                                    <span>{{ item.fjcyxm }}（{{ item.fssk }}）</span>
                                                </span>
                                            </div>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="2" v-if="!currentData.isApply  && formData.fxglx == '审评信息'">
                                        <span slot="label" class="descriptions-label-slot">
                                            原审评时间
                                        </span>
                                        <a-form-model-item >
                                            <span>{{ currentData.sjxd && currentData.sjxd.fyjckssj?currentData.sjxd.fyjckssj:'' }}</span> &emsp; 至 &emsp;
                                            <span>{{ currentData.sjxd && currentData.sjxd.fyjcjssj?currentData.sjxd.fyjcjssj:'' }}</span>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="2" v-if="!currentData.isApply  && formData.fxglx == '审评信息'">
                                        <span slot="label" class="descriptions-label-slot">
                                            现审评时间
                                        </span>
                                        <a-form-model-item >
                                            <a-range-picker
                                                v-if="!isView"
                                                :allowClear="false"
                                                :key="fxdjcsjKey"
                                                :defaultValue="[
                                                    currentData.sjxd && currentData.sjxd.fxdjckssj?moment(currentData.sjxd.fxdjckssj).format('YYYY-MM-DD'):'',
                                                    currentData.sjxd && currentData.sjxd.fxdjcjssj?moment(currentData.sjxd.fxdjcjssj).format('YYYY-MM-DD'):'']" 
                                                @change="onChangeInspect" 
                                            />
                                            <span v-else >
                                                <span>{{ currentData.sjxd && currentData.sjxd.fxdjckssj?currentData.sjxd.fxdjckssj:'' }}</span> &emsp; 至 &emsp;
                                                <span>{{ currentData.sjxd && currentData.sjxd.fxdjcjssj?currentData.sjxd.fxdjcjssj:'' }}</span>
                                            </span>
                                        </a-form-model-item>
                                    </a-descriptions-item>
                                    
                                </a-descriptions>
                            </a-form-model>
                        </div>
                        <div class="scheme-modification-boxx" v-if="!currentData.isApply && formData.fxglx == '方案修改'" >
                            <a-spin size="large" :spinning="programSpinning" :key="programSpinningKey" tip="正在加载中...">
                                <div v-if="schemeModificationData.id || isView" :key="programSpinningKey" style="width: 100%;text-align: flex;">
                                    <div v-if="schemeModificationData.id && !isView" >
                                        <a-button
                                        style="margin-right: 15px;" 
                                        class="blue-btn" type="primary" 
                                        @click="refreshFile">刷新</a-button>

                                        <a-button
                                        style="margin-right: 15px;" 
                                        class="blue-btn" type="primary" 
                                        @click="downloadFiles(schemeModificationData,'fwjxsmc')">下载</a-button>

                                        <a-button
                                        v-if="schemeModificationData.fwjlx == '.pdf'"
                                        style="margin-right: 15px;" 
                                        class="blue-btn" type="primary" 
                                        @click="reEdit(schemeModificationData)">重新编辑</a-button>

                                        <a-button
                                        v-if="schemeModificationData.fwjlx !== '.pdf'"
                                        style="margin-right: 15px;" 
                                        class="blue-btn" type="primary" 
                                        @click="saveFiles(schemeModificationData)">保存</a-button>

                                        <a-button
                                        v-if="schemeModificationData.fwjlx !== '.pdf'"
                                        style="margin-right: 15px;" 
                                        class="blue-btn" type="primary" 
                                        @click="generatePDFClick(schemeModificationData)">生成PDF</a-button>

                                        <!-- <a-button
                                        v-if="schemeModificationData.fwjlx == '.pdf'"
                                        style="margin-right: 15px;" 
                                        class="blue-btn" type="primary" 
                                        @click="stampClick">盖章</a-button>

                                        <a-button
                                        v-if="schemeModificationData.fwjlx !== '.pdf'"
                                        style="margin-right: 15px;"
                                        class="blue-btn" type="primary" 
                                        @click="generatePDFStampClick">生成PDF并盖章</a-button> -->

                                        <a-button 
                                        v-if="schemeModificationData.fwjlx !== '.pdf'"
                                        class="blue-btn" type="primary" 
                                        @click="reSelectTemplate(schemeModificationData)">重新选择模板</a-button>
                                    </div>
                                    <div v-if="schemeModificationData.id && isView" >
                                        <a-button
                                        style="margin-right: 15px;" 
                                        class="blue-btn" type="primary" 
                                        @click="refreshFile">刷新</a-button>
                                        <a-button
                                        style="margin-right: 15px;" 
                                        class="blue-btn" type="primary" 
                                        @click="downloadFiles(schemeModificationData,'fwjxsmc')">下载</a-button>
                                    </div>
                                    <div :key="iframeKey" style="display: flex;justify-content: center;" >
                                        <iframe 
                                            v-if="iframeSrc"
                                            :key="iframeKey"
                                            :src="iframeSrc" 
                                            ref="iframeServerEditingRef" 
                                            scrolling="auto" 
                                            width="100%"
                                            :height="windowInnerHeight - 370+'px'"
                                            style="border: 0;object-fit: contain !important;"
                                        ></iframe>
                                        <div v-else style="height:200px;">
                                            <a-empty description="暂无文件或文件发生错误！"/>
                                        </div>
                                    </div>
                                </div>
                                <div v-else >
                                    <span style="color: red;font-weight: 600;padding-left: 15px;">(注：当前暂无方案制定文件，请先选择模板进行方案制定)</span>
                                    <selectTemplateNoModel
                                    ref="selectTemplateNoModelRef" 
                                    @selectTemplateComplete="selectTemplateComplete" 
                                    @programSpinningChange="programSpinningChange" />
                                </div>
                            </a-spin>
                        </div>
                    </div>
                    <div v-if="activeKey == '流转记录'" class="dataRevision-increase-content">
                        <div style="width: 90%;" >
                            <commpVxeTable
                                ref="headmanVxeTable"
                                :key="internalOpinionsKey"
                                :config="internalOpinionsConfig" 
                                :columns="internalOpinionsColumnsVxe" 
                                :formItem="[]"
                                :adaptiveHeight="true"
                            >
                                <template v-slot:fblr_default="{row}">
                                    <span style="padding-right: 21;" v-if="row.fblr && row.fblr.length == 2">
                                        <span v-for="(trem,tI) in row.fblr.split('')" :key="tI" >
                                            {{trem}} 
                                            <span v-if="tI+1 !== row.fblr.split('').length">&nbsp;&nbsp;</span>
                                        </span>
                                    </span>
                                    <span style="padding-right: 21;" v-else>{{ row.fblr }}</span>
                                </template>
                            </commpVxeTable>
                        </div>
                    </div>
                </div>
            </a-spin>
            <addPersonnel ref="addPersonnelRef" @successChange="successChange" />
            <removePersonnel ref="removePersonnelRef" @successChange="successChange" />
            <processingConditionsAll ref="processingConditionsAllRef" :processingData="processingData" @interfaceSuccessful="interfaceSuccessful"></processingConditionsAll>
            <selectTemplate ref="selectTemplateRef" @selectTemplateComplete="selectTemplateComplete"/>
        </a-modal>
    </div>
</template>
<script>
import { 
    sjxdgetJobConcernByJobId, 
    sjxdfqsjxdFlow, 
    sjxdquerySjxdRyList, 
    sjxdaddSjxdXpry,
    sjxddeleteSjxdXpry, 
    sjxdupdateSjxdInfo, 
    sjxddeleteSjxdInfo, 
    sjxdquerySjxdFaWjList, 
    webOfficeApiopenFile,
    openFileReadOnly,
    getDocxToPdf,
    againEditPdfOnlineFile,
    spcySqsxWjjlgetLocalFileById,
} from './service/index'
import moment from 'moment'
import addPersonnel from './addPersonnel.vue'
import removePersonnel from './removePersonnel.vue'
import selectTemplateNoModel from '@/components/selectTemplate/selectTemplate-noModel.vue'
import selectTemplate from '@/components/selectTemplate/selectTemplate.vue'
import YchConstant from "@/api/YchConstant";
import blobType from '@/common/blobType'
import assessCheckApi from './service/api'
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
export default {
    components:{
        addPersonnel,
        removePersonnel,
        selectTemplateNoModel,
        selectTemplate,
        commpVxeTable,
    },
    props:{

    },
    data(){
        return{
            visible:false,
            currentData:{},
            spinning:false,
            spinningKey:null,
            formData:{},
            rules:{
                fxglx: [{ required: true, message: '请选择修改类型', trigger: 'change' }],
                fsqrq: [{ type: 'object', required: true, message: '请选择申请日期', trigger: 'change' }],
                fsqly: [{ required: true, message: '请输入申请理由', trigger: 'change' }],
            },
            dataRevisionIncreaseContentKey:null,
            checkInformationData:{
                sjxd:{},
                addList:[],
                removeList:[],
                orgList:[],
            },
            processingData:{},
            moment,
            fxdjcsjKey:null,
            schemeModificationData:{},
            programSpinning:false,
            programSpinningKey:null,
            iframeKey:null,
            iframeSrc:'',
            windowInnerHeight:window.innerHeight,
            activeKey:'数据修订信息',
            internalOpinionsKey:null,
            internalOpinionsConfig:{
                api:assessCheckApi.sjxdqueryJobHistoryList,
                rowId: 'id',
                // height:400,
                autoHidden:true,
                pageSize:10000,
                paramet:{}
            },
            internalOpinionsColumnsVxe:[{
                title: '环节名称',
                field: 'fhjmc',
                width:112,
            },{
                title: '待办人',
                field: 'fdbr',
            },{
                title: '办理人',
                field: 'fblr',
                width:70,
                slots: {
                    default:'fblr_default',
                }
            },{
                title: '发送时间',
                field: 'ffssj',
                width:165,
            },{
                title: '办理时间',
                field: 'fblsj',
                width:165,
            },{
                title: '使用工日',
                field: 'fsyts',
                width:86,
            },{
                title: '办理状态',
                field: 'fblzt',
                width:86,
            },{
                title: '办理意见',
                field: 'fblyj',
            }],
            isView:false,
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        async getData(row,view){
            this.isView = view?true:false
            let res ={}
            this.formData = {}
            //console.log('得到什么',row)
            if(row.fhjmc == '数据修订申请'){
                
                this.currentData = row
                res.code = 200
                
            }else{
                 res = await sjxdgetJobConcernByJobId({jobid:row.jobid})
                    if(res.code == 200){
                        //console.log(res)
                        row = {
                            ...row,
                            ...res.result.job,
                            ...res.result.sjxd,
                            ...res.result,
                        }
                        
                    }else{
                        this.$message.warning(res.message)
                    }
                    //console.log('我在这里1',row)
            }
            //console.log('我在这里2',row)
            this.currentData = row
            this.fxdjcsjKey = Date.now()
            //console.log('当前是什么数据',this.currentData)
            if(this.currentData.fhjmc !== '数据修订申请'){
                if(this.currentData.fxglx == '审评信息'){
                    this.getCheckInformation()
                }else{
                    this.getSchemeModification()
                }
            }
            
            this.formData = {
                fxglx:row.fxglx,
                fsqly:row.fsqly?row.fsqly:'',
                fsqrq:row.fsqrq?moment(row.fsqrq):moment(),
            }
            this.dataRevisionIncreaseContentKey = Date.now()
            this.visible = res.code == 200?true:false
            // this.currentData = row
        },
        tabPaneChange(val){
            if(val == '流转记录'){
                this.internalOpinionsConfig.paramet = {
                    id:this.currentData.sjxd.id
                }
                this.internalOpinionsKey = Date.now()
            }
            
        },
        getCheckInformation(){
            sjxdquerySjxdRyList({id:this.currentData.sjxd.id}).then(res=>{
                if(res.code == 200){
                    this.checkInformationData = {
                        sjxd:res.result && res.result.sjxd?res.result.sjxd:{},
                        addList:res.result && res.result.addList?res.result.addList:[],
                        removeList:res.result && res.result.removeList?res.result.removeList:[],
                        orgList:res.result && res.result.orgList?res.result.orgList:[],
                    }
                }else{
                    this.checkInformationData = {
                        sjxd:{},
                        addList:[],
                        removeList:[],
                        orgList:[],
                    }
                }
                //console.log('审评信息xxxxxxx',this.checkInformationData)
            })
        },
        getSchemeModification(){//获取方案数据
            sjxdquerySjxdFaWjList({id:this.currentData.sjxd.id}).then(res=>{
                if(res.code == 200){
                    //console.log('获取到什么方案数据',res.result[0])
                    this.programSpinning = true
                    if(res.result && res.result.length){
                        
                        this.schemeModificationData = res.result[0]
                        if(this.schemeModificationData.fwjlx == '.doc' || this.schemeModificationData.fwjlx == '.docx'){
                            this.openFileClick(this.schemeModificationData)
                        }else{
                            this.iframeSrc = bootConfig[process.env.NODE_ENV].locality_ApI + YchConstant.SPZX_SPCY + '/spcyRsWjmb/openWjjl?id='+this.schemeModificationData.id
                            this.iframeKey = Date.now()
                            this.programSpinning = false
                        }
                    }else{
                        if(!this.isView){
                            this.$nextTick(()=>{
                                this.$refs.selectTemplateNoModelRef.getSelectTemplate({listApi:'spcyRsWjmbsjxdFlMbList',okFun:'sjxdinitSjxdMb',},'审评方案',{id:this.currentData.sjxd.id})
                                this.$refs.selectTemplateNoModelRef.selectTemplateVisible = true
                            })
                        }
                        
                        
                        this.schemeModificationData = {}
                        this.programSpinning = false
                    }
                }else{
                    this.schemeModificationData = {}
                    this.programSpinning = false
                }

            })
        },
        refreshFile(){
            this.openFileClick(this.schemeModificationData)
        },
        openFileClick(val){
            if(this.isView){
                openFileReadOnly({id:val.id}).then(res=>{
                    if(res.code == 200){
                        this.iframeSrc = res.result.wordUrl
                        this.iframeKey = Date.now()
                    }else{
                        this.iframeSrc = ''
                        this.$message.warning(res.message)
                    }
                    this.programSpinning = false
                })
            }else{
                webOfficeApiopenFile({id:val.id}).then(res=>{
                    if(res.code == 200){
                        this.iframeSrc = res.result.wordUrl
                        this.iframeKey = Date.now()
                    }else{
                        this.iframeSrc = ''
                        this.$message.warning(res.message)
                    }
                    this.programSpinning = false
                })
            }
            
        },
        
        downloadFiles(val){//下载
            var that = this
            var fwjlx = val.fwjlx?val.fwjlx:val.fclmc.slice(val.fclmc.lastIndexOf('.'))
            let param = { id:val.id,}
            spcySqsxWjjlgetLocalFileById(param).then((data) => {
                if (!data) {
                    that.$message.warning('文件下载失败')
                return
                }
                    let url = window.URL.createObjectURL(new Blob([data], { type: blobType.type[blobType.suffix.indexOf(fwjlx)] }))
                    let link = document.createElement('a')
                    link.style.display = 'none'
                    link.href = url
                    link.setAttribute('download', name?val[name]:val.fwjxsmc?(val.fwjxsmc+val.fwjlx):(val.fwjccmc?(val.fwjccmc+val.fwjlx):val.fclmc) )
                    document.body.appendChild(link)
                    link.click()
                    document.body.removeChild(link) //下载完成移除元素
                    window.URL.revokeObjectURL(url) //释放掉blob对象
            })
        },
        reEdit(val){//重新编辑
            againEditPdfOnlineFile({id:val.id}).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.getSchemeModification()
                }else{
                    this.$message.warning(res.message)
                    this.programSpinning = false
                }
            })
        },
        saveFiles(val){//保存
            this.programSpinning = true
            getWebOfficeDownloadFile({id:val.id}).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.refreshFile()
                }else{
                    this.$message.warning(res.message)
                    this.programSpinning = false
                }
            })
        },
        generatePDFClick(val){//生成pdf
            this.programSpinning = true
            getDocxToPdf({id:val.id}).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.getSchemeModification()
                }else{
                    this.$message.warning(res.message)
                    this.programSpinning = false
                }
            })
        },
        reSelectTemplate(){//重新选择模板
            this.$refs.selectTemplateRef.getSelectTemplate({listApi:'spcyRsWjmbsjxdFlMbList',okFun:'sjxdinitSjxdMb',},'审评方案',{id:this.currentData.sjxd.id})
            this.$refs.selectTemplateRef.selectTemplateVisible = true
        },
        selectTemplateComplete(){
            this.getSchemeModification()
        },
        programSpinningChange(){

        },
        successChange(){
            this.getCheckInformation()
        },
        refreshClick(){//刷新
            this.dataRevisionIncreaseContentKey = Date.now()
            this.getData(this.currentData)
        },
        initiateApplicationClick(){//发起申请
            //console.log(this.formData)
            this.$refs.ruleForm.validate(valid => {
                //console.log(valid)
                if (valid) {
                    let data = {
                        sqsxid:this.currentData.sqsxid,
                        jobid:this.currentData.jobid,
                        ...this.formData,
                    }
                    sjxdfqsjxdFlow(data).then(res=>{
                        if(res.code == 200){
                            //console.log('发起后得到什么',res)
                            this.$message.success(res.message)
                            // this.getData({...this.currentData,fhjmc:'',isApply:false})
                            let row = {
                                ...row,
                                isApply:false,
                                ...res.result.job,
                                ...res.result.sjxd,
                                ...res.result,
                                jobid:res.result.job.id,
                            }
                            this.currentData = row
                            this.fxdjcsjKey = Date.now()
                            //console.log('当前是什么数据',this.currentData)
                            if(this.currentData.fhjmc !== '数据修订申请'){
                                if(this.currentData.fxglx == '审评信息'){
                                    this.getCheckInformation()
                                }else{
                                    this.getSchemeModification()
                                }
                            }
                            
                            this.formData = {
                                fxglx:row.fxglx,
                                fsqly:row.fsqly?row.fsqly:'',
                                fsqrq:row.fsqrq?moment(row.fsqrq):moment(),
                            }
                        }else{
                            this.$message.warning(res.message)
                        }
                    })
                } else {
                    //console.log('error submit!!');
                    return false;
                }
            });
        },
        updateData(name,val){//更新信息
            if(this.currentData.fhjmc !== '数据修订申请' &&  this.currentData.sjxd && this.currentData.sjxd.id){
                let data = {
                    id:this.currentData.sjxd.id,
                }
                if(typeof name == 'string'){
                    data[name] = val
                }else{
                    data = {
                        ...data,
                        ...name,
                    }
                }
                sjxdupdateSjxdInfo(data).then(res=>{
                    if(res.code == 200){
                        this.$message.success(res.message)
                    }else{
                        this.$message.warning(res.message)
                    }
                })
            }
            
        },
        addPersonnelClick(){//新增人员
            this.$refs.addPersonnelRef.getData({id:this.currentData.sjxd.id})
            this.$refs.addPersonnelRef.visible = true
        },
        removePersonnelClick(){//移除人员
            this.$refs.removePersonnelRef.getData({id:this.currentData.sjxd.id})
            this.$refs.removePersonnelRef.visible = true
        },
        personnelChanges(val,type){
            var that = this
            this.$confirm({
                title:'您确认要'+type+'吗？',
                // icon: createVNode(ExclamationCircleOutlined),
                onOk() {
                    let data = {
                        id:val.id
                    }
                    sjxddeleteSjxdXpry(data).then(res=>{
                        if(res.code == 200){
                            that.$message.success(res.message)
                            that.getCheckInformation()
                        }else{
                            that.$message.warning(res.message)
                        }
                    })
                },
                
            });
        },
        onChangeInspect(val,val1){
            //console.log(val,val1)
            let data = {
                fxdjckssj:val1[0],
                fxdjcjssj:val1[1],
            }
            this.updateData(data)
        },
        fsqrqChange(val,val1){
            this.updateData('fsqrq',val1)
        },
        revokeChange(){//撤销申请
            var that = this
            this.$confirm({
                title:'您确认要撤销申请吗？',
                // icon: createVNode(ExclamationCircleOutlined),
                onOk() {
                    let data = {
                        jobid:that.currentData.job.id
                    }
                    sjxddeleteSjxdInfo(data).then(res=>{
                        if(res.code == 200){
                            that.$message.success(res.message)
                            that.interfaceSuccessful()
                        }else{
                            that.$message.warning(res.message)
                        }
                    })
                },
                
            });
        },
        returnProcess(){
            this.$refs.processingConditionsAllRef.processingConditionsVisible = true
            let data = {
                interface:'sjxdreturnFlowJob',
                sqsxid:this.currentData.sqsxid,
                nextNodeDbrList:this.currentData.nextNodeDbrList,
                nextNode:this.currentData.nextNode,
                jobid:this.currentData.jobid,
                isBlr:false,
                isThhj:true,
                isXyb:false,
                headerLeftTitle:'退回',
                headerCenterTitle:'数据修订--'+this.currentData.fhjmc,
                isNew:true,
                NoViewBlr:true,
                recordApi:'sjxdqueryJobHistoryList',
                id:this.currentData.sjxd.id,
                isDxtx:false,
            }
            this.processingData = data
            this.$refs.processingConditionsAllRef.getData(data)
        },
        linkHandling(val){
            this.$refs.processingConditionsAllRef.processingConditionsVisible = true
            let data = {
                interface:val,
                nextNodeDbrList:this.currentData.nextNodeDbrList,
                nextNode:this.currentData.nextNode,
                jobid:this.currentData.jobid,
                headerLeftTitle:'提交',
                headerCenterTitle:'数据修订--'+this.currentData.fhjmc,
                otherData:{
                    // fscms:'技术审评',
                },
                isBlr:false,
                isNew:true,
                isDxtx:false,
                recordApi:'sjxdqueryJobHistoryList',
                id:this.currentData.sjxd.id,
            }
            this.processingData = data
            this.$refs.processingConditionsAllRef.getData(data)
        },
        interfaceSuccessful(){
            this.$emit('successChange')
            this.visible = false
        }
    }
}
</script>
<style lang="less">
.full-dataRevision-modal{
    .ant-modal {
    max-width: 100%;
    top: 0;
    padding-bottom: 0;
    margin: 0;
  }
    .ant-modal-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
  .ant-modal-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh);
    // background: #fff;
  }
  .ant-modal-body {
    flex: 1;
    background: #f4f7fc !important;
    padding: 0px;
    height: calc(100vh - 50px);
    overflow: auto;
  }
  .ant-modal-footer{
    display: none;
  }
  .dataRevision-content-box{

  }
  .dataRevision-increase-content{
    border: 1px solid #38f;
    border-top: none;
    background-color: #fff;
    width: 100%;
    // margin-top: 8px;
    display: flex;
    // justify-content: center;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    height: calc(100vh - 155px);
    overflow: auto;
    .dataRevision-toolbox-form-box1{
        display: flex;
        flex-wrap: wrap;
        width: 90%;
        .form-model-big-box{
            width: 100%;
        }
        .Empty-lin-box{

        }
        .undefined-item-content{
            height: 40px !important;
        }
        .ant-descriptions-bordered .ant-descriptions-item-label{
            font-weight: 600;
            color: rgba(0, 0, 0, 0.85);
            background-color:#e6f7ff;
            width: 88px !important;
            text-align: right;
            font-family:simHei !important;
        }
        .ant-descriptions-bordered .ant-descriptions-item-label, .ant-descriptions-bordered .ant-descriptions-item-content{
            padding: 3px 10px !important;
            
        }
        .descriptions-label-slot{
            display: flex;
            align-items: center;
            justify-content: flex-end;
            width: 71px !important;//确保左侧固定文字不会换行
        }
        .xhText{
            display: inline-block;
            color: #f5222d;
            line-height: 31px;
            padding-right: 2px;
            font-size: 14px;
            font-weight: 600;
            height: 30px;
        }
        .descriptions-item-center{
            
        }
        .ant-form-inline .ant-form-item-with-help{
            margin-bottom: 0px !important;
        }
        .zm-form-model{
            display: flex;
            .ant-form-item-control-wrapper{
                flex: 1;
            }
        }
        .ant-form-item-control{
            min-height: 40px;
        }
        .ant-form-item-control-wrapper{
            font-family:仿宋_GB2312 !important;
        }
        .ant-descriptions-bordered .ant-descriptions-row{
            border-bottom: 1px solid #e4e3e3;
        }
        .ant-descriptions-bordered .ant-descriptions-item-label, .ant-descriptions-bordered .ant-descriptions-item-content{
            border-right: 1px solid #e4e3e3;
        }
        .ant-descriptions-bordered .ant-descriptions-view{
            border: 1px solid #e4e3e3;
            border-right: 0;
        }
        .ant-descriptions-row:last-child{
            border-bottom: 0;
        }
        .ant-form-item-children{
            color: #242424 !important;
        }
    }
    .fjcyxm-list-box{
        .fjcyxm-item-v{
            display: inline-block;
            height: auto;
            border: 1px solid #38f;
            // font-weight: 600;
            margin-left: 8px;
            padding: 0 3px;
            line-height: 30px;
            border-radius: 5px;
            color: #242424;
        }
        .minus-circle-icon{
            color: #ed5565;
            font-size: 18px;
        }
        .plus-circle-icon{
            color: #1ab394;
            font-size: 18px;
        }
    }
    
  }
  .scheme-modification-boxx{
    margin-top: 8px;
    width: 90%;
    border: 1px solid #d9d9d9;
  }
}
</style>